import "./public-path";
import Vue from "vue";
import App from "./App.vue";

Vue.config.productionTip = false;

let vm = null;
// 渲染方法
function render(props = {}) {
  const { container } = props;

  vm = new Vue({
    render: (h) => h(App),
  }).$mount(container ? container.querySelector("#app") : "#app");
}

// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}

export async function bootstrap(props) {
  // 准备工作
  const state = props.actions.getGlobalState();
  console.log(state);
  // store.state.user.token = state.token
}
export async function mount(props) {
  // 挂载微应用
  render(props);
}
export async function unmount() {
  // 卸载微应用
  vm.$destroy();
  vm.$el.innerHTML = "";
  vm = null;
}
